package com.youzhi.backend.controller;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.youzhi.backend.dto.Result;
import com.youzhi.backend.request.AddPrivilegeRequest;
import com.youzhi.backend.request.GetPrivilegeRequest;
import com.youzhi.backend.service.IRolePrivilegeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 角色权限表 前端控制器
 * </p>
 *
 * @author xumeng
 * @since 2022-11-18
 */
@RestController
@Api(tags = "角色权限")
@RequestMapping("/rolePrivilege")
public class RolePrivilegeController extends BaseController {


    @Autowired
    private IRolePrivilegeService service;


    @ApiOperation("获取角色权限信息")
    @PostMapping("/codes")
    public Result getPrivilegeCodes(@RequestBody GetPrivilegeRequest request) {
        verifyIfBlank(request, AddPrivilegeRequest.Fields.roleId);
        List<String> codes = service.getPrivilegeCodes(request.getRoleId());
        return Result.ok(codes);
    }


}

